import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'

Vue.use(VueRouter)

const routes = [
  
  {
    path: '/',
    name: 'home',
    component: HomeView
   
  },
  {//页面跳转部分-懒加载
    path: '/LoginView',
    name: 'LoginView',
    component: () => import('../views/LoginView.vue')
  },
  {
    path: '/ShoppingCart',
    name: 'ShoppingCart',
    component: () => import('../views/ShoppingCart.vue')

  },
  {
    path:"/SearchView",
    name:"SearchView",
    component:()=>import("../views/SearchView.vue")
  },
   {
    path:"/RegisterView",
    name:"RegisterView",
    component:()=>import("../views/RegisterView.vue")
  },
  {
    path:"/ProductView",
    name:"ProductView",
    component:()=>import("../views/ProductView.vue")
  },
  {
    path:"/PurchasedView",
    name:"PurchasedView",
    component:()=>import("../views/PurchasedView.vue")
  },
  {
    path:"/FavoriteBabyView",
    name:"FavoriteBabyView",
    component:()=>import("../views/FavoriteBabyView.vue")
  },
  {
    path:"/FavoriteShopView",
    name:"FavoriteShopView",
    component:()=>import("../views/FavoriteShopView.vue")
  },
  {
    path:"/MyTaobaoView",
    name:"MyTaobaoView",
    component:()=>import("../views/MyTaobaoView.vue")
  },
  {
    path:"/PurchasedShop",
    name:"PurchasedShop",
    component:()=>import("../views/PurchasedShop.vue")
  },
  {
    path:"/MyFootView",
    name:"MyFootView",
    component:()=>import("../views/MyFootView.vue")
  },
  {
    path:"/RefundView",
    name:"RefundView",
    component:()=>import("../views/RefundView.vue")
  },
  {
    path:"/EvaluationManView",
    name:"EvaluationManView",
    component:()=>import("../views/EvaluationManView.vue")
  },
  {
    path:"/SecuritySetting",
    name:"SecuritySetting",
    component:()=>import("../views/SecuritySetting.vue")
  },
  {
    path:"/AddressView",
    name:"AddressView",
    component:()=>import("../views/AddressView.vue")
  },
  {
    path:"/PersonalData",
    name:"PersonalData",
    component:()=>import("../views/PersonalData.vue")
  },
  {
    path:"/EnterShop",
    name:"EnterShop",
    component:()=>import("../views/EnterShop.vue")
  },

]
const router = new VueRouter({
  routes
})
//------------重复导航一个页面会报错，这是全局处理器---------------
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => {
    // 只捕获重复导航的错误，其他错误仍然抛出
    if (err.name !== 'NavigationDuplicated') {
      throw err;
    }
  });
};
//----------------------------------------------------------------

export default router
